package cc.atliberty.creating.prototype.ex0;

import java.util.UUID;

/**
 * @Author 元宵
 * @url www.atliberty.cc
 * @Date 2023-10-30 20:08
 * @description:
 */
public class Client {
    private static int MAX_COUNT = 1000000;

    public static void main(String[] args) {
        int i = 0;
        Mail mail = new Mail(new AdvTemplate());
        mail.setTail("XXX银行版权所有");
        long startTime = System.currentTimeMillis();
        while (i < MAX_COUNT) {
            mail.setAppellation(getRandString(5) + "先生(女士)");
            mail.setReceiver(getRandString(5) + "@" + getRandString(8) + ".com");
            sendMail(mail);
            i++;
        }
        long time = System.currentTimeMillis() - startTime;
        System.out.println(time + "ms");
    }

    private static void sendMail(Mail mail) {
        System.out.println("标题: " + mail.getSubject() + "\t收件人: " + mail.getReceiver() + "\t....发送成功!!");
    }

    private static String getRandString(int maxLength) {
        String source = UUID.randomUUID().toString();
        return source.substring(0, maxLength);
    }
}
